# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=prometheus-ceph-exporter
pkgver=4.2.4
pkgrel=1
pkgdesc="Prometheus exporter that scrapes meta information about a ceph cluster"
url="https://github.com/digitalocean/ceph_exporter"
license="Apache-2.0"
# riscv64, 32bit: doesn't build
arch="all !x86 !armhf !armv7"
makedepends="
	ceph-dev
	linux-headers
	go
	"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/digitalocean/ceph_exporter/archive/refs/tags/$pkgver.tar.gz
	ceph-exporter.initd
	ceph-exporter.confd
	0001-fix-build-error-on-loongarch64.patch
	"
builddir="$srcdir/ceph_exporter-$pkgver"
options="net"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -o ceph-exporter -tags "quincy reef" # support ceph 16 and 18
}

check() {
	go test -tags "quincy reef" ./...
}

package() {
	install -Dm755 ceph-exporter -t "$pkgdir"/usr/bin/

	install -Dm755 "$srcdir"/ceph-exporter.initd "$pkgdir"/etc/init.d/ceph-exporter
	install -Dm644 "$srcdir"/ceph-exporter.confd "$pkgdir"/etc/conf.d/ceph-exporter
}

sha512sums="
5f6b1c94df8f8a9452ce64549fa78f38c16d6f14f455f2f79274a952dbe6c0b8258abede4b99a8f8679f649519f3922f350443e37f681c5a7887a62f00146d6a  prometheus-ceph-exporter-4.2.4.tar.gz
392448b600c3dab44718ccf3133fdc349ebc840f9fe4f8445be10bcc3c4c65cd7db96babe52ae9cec8cbf22d72865bd6794da1b4ee990c279d586b08c8dd8b3e  ceph-exporter.initd
2278273061c1f8e216193f1b0a00dbe0d791c460b803ff14408f1519bf2ee7daf402162741057a648747be9647510215d262f1e1672cd1cab0224a7e9175af53  ceph-exporter.confd
817873628444249eb1453b40c78f8e1f7c51d6acb6c06022f17a1c0ef72caad583326ebf235e744beaae14c57a66e7203acfe9a007739e8357c7d31db5fb78a9  0001-fix-build-error-on-loongarch64.patch
"
